home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 2002 #3
/
Amiga Plus CD - 2002 - No. 03.iso
/
AmiSoft
/
Util
/
Misc
/
Lottery2002.lha
/
Lottery2002
/
Source
/
gui.c
< prev
next >
Wrap
C/C++ Source or Header
|
2002-11-26
|
4KB
|
176 lines
/* gui.c */
#include "includes.h"
#include "externals.h"
BOOL opengui()
{
struct TextAttr helvetica= {"helvetica.font", 24, FS_NORMAL, FPF_DISKFONT};
struct MsgPort *AppPort;
struct Window *win;
struct Gadget *gadgets[GAD_LAST];
struct DiskObject *diskobj;
Object *object;
if(diskobj = GetDiskObject("PROGDIR:Lottery2002"));
{
diskobj->do_CurrentX = NO_ICON_POSITION;
diskobj->do_CurrentY = NO_ICON_POSITION;
}
if(!(setmenus())) return(TRUE);
if (!(AppPort = CreateMsgPort()))
{
FreeMenus(g_menustrip);
requester(g_title,
"Could not open Message Port.", g_button);
return(TRUE);
}
/* Create the Window object & attach the menus & buttons */
object = WindowObject,
WA_ScreenTitle, g_scrtitle,
WA_Title, "Lottery2002 © T.Collier",
WA_Activate, TRUE,
WA_DepthGadget, TRUE,
WA_DragBar, TRUE,
WA_CloseGadget, TRUE,
WA_SizeGadget, TRUE,
WINDOW_GadgetHelp, TRUE,
WINDOW_MenuStrip, g_menustrip,
WINDOW_IconifyGadget, TRUE,
WINDOW_Icon, diskobj,//GetDiskObject("PROGDIR:Lottery2002"),
WINDOW_IconTitle, "Lottery2002",
WINDOW_AppPort, AppPort,
WINDOW_Position, WPOS_CENTERSCREEN,
WINDOW_ParentGroup, gadgets[GAD_FIRST] = VGroupObject,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_DeferLayout, TRUE,
StartHGroup,
Offset(INTERSPACE,INTERSPACE/2,INTERSPACE,INTERSPACE),
LAYOUT_BevelStyle, BVS_GROUP,
LAYOUT_Label, "Your Lottery Numbers For Wednesday",
LOTTO_Box(GAD_BOX1),
LOTTO_Box(GAD_BOX2),
LOTTO_Box(GAD_BOX3), // My macros, defined in includes.h
LOTTO_Box(GAD_BOX4),
LOTTO_Box(GAD_BOX5),
LOTTO_Box(GAD_BOX6),
EndHGroup,
CHILD_WeightedHeight, 0,
StartHGroup,
Offset(INTERSPACE,INTERSPACE/2,INTERSPACE,INTERSPACE),
LAYOUT_BevelStyle, BVS_GROUP,
LAYOUT_Label, "Your Lottery Numbers For Saturday",
LOTTO_Box(GAD_BOX7),
LOTTO_Box(GAD_BOX8),
LOTTO_Box(GAD_BOX9), // My macros, defined in includes.h
LOTTO_Box(GAD_BOX10),
LOTTO_Box(GAD_BOX11),
LOTTO_Box(GAD_BOX12),
EndHGroup,
CHILD_WeightedHeight, 0,
StartHGroup,
StartMyFuelGauge(GAD_FUEL, 235, FALSE), // MyFuelGauge macro defined in includes.h
EndHGroup,
CHILD_WeightedHeight, 0,
StartHGroup, // StartMyButton is my macro, defined in includes.h
StartMyButton(GAD_START, "_Start", FALSE),
BUTTON_SoftStyle, FSF_BOLD,
ButtonEnd,
StartMyButton(GAD_SPEAK, "Sp_eak", spk_flag ^ 1),
ButtonEnd,
StartMyButton(GAD_QUIT, "_Quit", FALSE),
ButtonEnd,
EndHGroup,
CHILD_WeightedHeight, 0,
EndGroup,
EndWindow;
if (!(object)) // Did we get the object created ?
{
requester(g_title,
"Could not create Window Object.", g_button);
ClearMenuStrip(win);
FreeMenus(g_menustrip);
DeleteMsgPort(AppPort);
return(TRUE);
}
if(win = (struct Window *) RA_OpenWindow(object))
{
get_num(win, gadgets);
events(AppPort, object, gadgets, win);
}
else
{
requester(g_title,
"Could not open Window.", g_button);
}
FreeMenus(g_menustrip);
DeleteMsgPort(AppPort);
DisposeObject(object);
return(TRUE);
}
/* I have used the Menu Macros defined in "reaction_macros.h" **
** except for the Speak menu item as I need access to the nm_flags, **
** in order to disable it if no narrator.device was found in DEVS: */
BOOL setmenus(void)
{
BOOL flag = TRUE;
void *vi = NULL;
struct Screen *scr = NULL;
struct NewMenu mymenu[] =
{
Title("Project"),
Item("Start", "S",0),
{NM_ITEM, "Speak", "E",spk_flag > 0 ? 0 : NM_ITEMDISABLED, 0, 0,},
ItemBar,
Item("About...","A",0),
Item("Iconify", "I",0),
ItemBar,
Item("Quit", "Q",0),
EndMenu,
};
if (scr = LockPubScreen(NULL))
{
if (vi = GetVisualInfo(scr, TAG_END))
{
if(g_menustrip = CreateMenus(mymenu, TAG_END))
{
if(LayoutMenus(g_menustrip, vi, GTMN_NewLookMenus, TRUE,TAG_END))
{
; // Do nothing!
}
else
flag =requester(g_title, "Could NOT LAYOUT Menus.", g_button);
}
else
flag = requester(g_title, "Could NOT CREATE Menus.", g_button);
FreeVisualInfo(vi);
}
else
flag = requester(g_title, "Could NOT GET\nScreen Visual Info", g_button);
UnlockPubScreen(NULL, scr);
}
else
flag = requester(g_title, "Could NOT LOCK\nDefault Public Screen", g_button);
return(flag);
}